<?php 
/*
* @author Elisa Conesa <econesa@gmail.com>
*/

class Lista {

	//
	// Lista de elementos positivos o strings implementada con el patron Iterator.
	//
	
	protected $lista;
	protected $index;
	protected $size;
	protected $max;
	
	
	public function create( $lista = array() ) {
		$this->lista = $lista;
		$this->index = 0;
		$this->size	 = count($lista)-1;
		$this->max	 = -1;
	}
	
	public function showRow() {
		echo "Fila ".$this->index." = {".$this->lista[$this->index][0].", ".$this->lista[$this->index][1]."}<br/>";
	}
	
	public function setRow( $r, $value ) {
		$this->lista[$this->index][$r] = $value;
	}
	
	public function getIndex( ) {
		return $this->index;
	}
	
	public function isDone() {
		return ($this->size < $this->index);
	}
	
	public function first() {
		$this->index = 0;
	}
	
	public function next() {
		$this->index++;
		$this->size = count($this->lista)-1;
	}
	
	public function item() {
		return $this->lista[$this->index];
	}
	
	public function itemAt( $index ) {
		return $this->lista[$index];
	}
	
	public function setMax( $max ) {
		$this->max = $max;
	}
	
	public function getMax() {
		return $this->max;
	}
	
	public function getArray() {
		return $this->lista;
	}
	
}

?>
